import java.util.HashMap;

/**
 * This class represents a CookieBox
 *
 */
@Author("David Schibl")
public class CookieBox {
	private HashMap<Cookie, Integer> cookies=null;
	
	public CookieBox(){
		cookies=new HashMap<Cookie, Integer>();
	}
	/**
	 * @return
	 * 		Returns a descriptive string of the cookies inside the Box
	 */
	@Author("David Schibl")
	public String inhalt(){
		if(cookies.isEmpty()) return "No cookies CookieBox";
		
		String temp="Content of CookieBox:\n";
		for(Cookie keks: cookies.keySet()){
			temp+=cookies.get(keks)+"x "+keks.toString()+"\n";
		}
		return temp;
	}
	/**
	 * Adds a cookie in the cookiebox
	 */
	@Author("David Schibl")
	public void add(Cookie newcookie){
		//newcookie != null
		
		for(Cookie keks: cookies.keySet()){
			if(keks.equals(newcookie)){
				int value = cookies.get(keks) + 1;
				cookies.put(keks, value);
				return;
			}
		}
		cookies.put(newcookie, 1);
	}
	
}
